#include "pch.h"
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>

using namespace std;

template<class T>

int length(T& arr)
{
	return sizeof(arr) / sizeof(arr[0]);
}

class cat
{
public:
	cat();
	void GetCatInform() const;
	string getcateyecolor() const { return this->eyecolor; }
	string getcatfurcolor() const { return this->furcolor; }
	string getcatfurlength() const { return this->furlength; }
	void ModifyCatInform(string, string, string);
	static int furcolornum[];
	static int eyecolornum[];
private:
	string eyecolor, furcolor, furlength;
	static const string eyecolorlist[];
	static const string furcolorlist[];
	static const string furlengthlist[];
};

class cage
{
public:
	cage* insertcage(cage *p);
	void changecase(cage *p, int, cat);
	cat getvalue() const { return this->value; }
private:
	cat value;
	cage *next = NULL;
};

const string cat::eyecolorlist[] = { "green","blue","brown" };
const string cat::furcolorlist[] = { "black", "gray", "brown" };
const string cat::furlengthlist[] = { "long","short" };
int cat::furcolornum[] = { 0,0,0 };
int cat::eyecolornum[] = { 0,0,0 };

cat::cat() :eyecolor(eyecolorlist[rand() % length(eyecolorlist)]), furcolor(furcolorlist[rand() % length(furcolorlist)]), furlength(furlengthlist[rand() % length(furlengthlist)])
{
	for (int i = 0;i < 3;i++)
	{
		if ((this->furcolor) == furcolorlist[i])
			furcolornum[i]++;
		if ((this->eyecolor) == eyecolorlist[i])
			eyecolornum[i]++;
	}
}

void cat::GetCatInform() const
{
	cout << "furcolor is " << furcolor << endl;
	cout << "eyecolor is " << eyecolor << endl;
	cout << "furlength is " << furlength << endl;
}

void cat::ModifyCatInform(string TempStr1, string TempStr2, string TempStr3)
{
	this->eyecolor = TempStr1;
	this->furcolor = TempStr2;
	this->furlength = TempStr3;
}

cage* cage::insertcage(cage *p)
{
	cage *node = new cage;
	node->next = p->next;
	p->next = node;
	return node;
}

void cage::changecase(cage *head, int n, cat temp)
{
	cage *p;
	p = head;
	for (int i = 0;i < n;i++)
	{
		p = p->next;
	}
	p->value = temp;
}

int main()
{
	srand((int)time(0));
	bool flag = false;
	cout << "Please press Enter to creat cats,if you press other Key,the course will be close." << endl;
	char Tempc1 = cin.get();
	if (Tempc1 == '\n')
	{
		cage *head = new cage;
		cage *list = head;
		head->getvalue().GetCatInform();
		while (1)
		{
			char Tempc2 = cin.get();
			if (Tempc2 != '\n')
				break;
			list = (*list).insertcage(list);
			list->getvalue().GetCatInform();
		}
		if ((((((*head).getvalue()).furcolornum[0]) != (((*head).getvalue()).furcolornum[1])) && ((((*head).getvalue()).furcolornum[0]) != 0) && ((((*head).getvalue()).furcolornum[1]) != 0)) || (((((*head).getvalue()).furcolornum[1]) != (((*head).getvalue()).furcolornum[2])) && ((((*head).getvalue()).furcolornum[1]) != 0) && ((((*head).getvalue()).furcolornum[2]) != 0)) || (((((*head).getvalue()).furcolornum[0]) != (((*head).getvalue()).furcolornum[2])) && ((((*head).getvalue()).furcolornum[0]) != 0) && ((((*head).getvalue()).furcolornum[2]) != 0)))
		{
			cout << "They will Fight" << endl;
			flag = true;
		}
		if (flag == false)
			if (!((((((*head).getvalue()).eyecolornum[0]) != 0) && ((((*head).getvalue()).eyecolornum[1]) == 0) && ((((*head).getvalue()).eyecolornum[2]) == 0)) || (((((*head).getvalue()).eyecolornum[0]) == 0) && ((((*head).getvalue()).eyecolornum[1]) != 0) && ((((*head).getvalue()).eyecolornum[2]) == 0)) || (((((*head).getvalue()).eyecolornum[0]) == 0) && ((((*head).getvalue()).eyecolornum[1]) == 0) && ((((*head).getvalue()).eyecolornum[2]) != 0))))
			{
				cout << "They will Fight" << endl;
				flag = true;
			}
		if (flag == false)
			cout << "They will not Fight" << endl;
	}
	else
	{
		cout << "The cage don't have cat." << endl;
		return 0;
	}
}